You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
"use strict";
// ru-code: dev-link install hook (GITIGNORED, local-dev only — see the `# cross-repo link`
// block at the end of .gitignore; same mechanism the pixso-move package documented).
//
// Switch: the gitignored `ru-code-packages` symlink at the repo root (→ the local
// ru-code-packages checkout). If it exists, every `@smart-tools/*` dependency that has a
// matching `packages/<name>` directory there is rewritten to `link:<abs path>` at install
// time — the host consumes the LOCAL BUILDS live via symlink (rebuild in the packages repo;
// no reinstall, no in-repo copies). Without the symlink (CI, forkers, other machines) this
// file is absent or inert and everything installs from the registry as the manifests say.
//
// Runtime caveat the link: protocol brings: a linked package resolves ITS imports from the
// packages repo's node_modules, so shared libs (`effect`, react, …) can load twice — the app
// vite configs dedupe them back to the host's single (patched) copy (`resolve.dedupe`).
const fs = require("node:fs");
const path = require("node:path");
const packagesDir = path.join(__dirname, "ru-code-packages", "packages");
const SCOPE = "@smart-tools/";
const linkActive = fs.existsSync(packagesDir);
function relinkDependencies(dependencies) {
if (dependencies === undefined || dependencies === null) {
return;
}
for (const dependencyName of Object.keys(dependencies)) {
if (!dependencyName.startsWith(SCOPE)) {
continue;
}
const localDir = path.join(packagesDir, dependencyName.slice(SCOPE.length));
if (fs.existsSync(localDir)) {
// Absolute real path: manifests live at different depths and worktrees move around.
dependencies[dependencyName] = `link:${fs.realpathSync(localDir)}`;
}
}
}
module.exports = {
hooks: {
readPackage(pkg) {
if (!linkActive) {
return pkg;
}
relinkDependencies(pkg.dependencies);
relinkDependencies(pkg.devDependencies);
relinkDependencies(pkg.optionalDependencies);
return pkg;
},
},
};
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.